package com.story.aistory.controller;


import com.story.aistory.domain.po.ReadRecord;
import com.story.aistory.service.IReadRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hui
 * @since 2025-03-12
 */
@RestController
@RequestMapping("/read")
@RequiredArgsConstructor
@Tag(name = "读书记录")
public class ReadRecordController {
    private final IReadRecordService readRecordService;

    @GetMapping("/add")
    @Operation(summary = "添加记录")
    public void add(@PathVariable("storyId") Integer storyId){
        readRecordService.add(storyId);
    }

    @GetMapping("/delete")
    @Operation(summary = "删除记录")
    public void delete(@PathVariable("storyId") Integer storyId){
        readRecordService.delete(storyId);
    }

    @GetMapping("/deleteall")
    @Operation(summary = "删除所有记录")
    public void deleteAll(){
        readRecordService.deleteAll();
    }
    @GetMapping("/getall")
    @Operation(summary = "获取所有记录")
    public List<ReadRecord> getAll() {
        return readRecordService.getAll();
    }
}
